package com.screenworker.compactmvc.examples.flex.modules.dummymodule.model
{
	import com.screenworker.compactmvc.examples.flex.ApplicationController;
	import com.screenworker.compactmvc.examples.flex.common.ApplicationConstants;
	import com.screenworker.compactmvc.examples.remoting.vo.ExampleServiceVO;
	import com.screenworker.compactmvc.extensions.remotingservice.RemotingService;
	import com.screenworker.compactmvc.extensions.remotingservice.interfaces.IRemotingService;
	import com.screenworker.compactmvc.interfaces.IModel;
	import com.screenworker.compactmvc.patterns.Controller;
	
	import flash.net.registerClassAlias;
	
	import mx.controls.Alert;

	public class RemotingModel extends RemotingService implements IRemotingService, IModel
	{
		public static const NAME:String = 'RemotingModel';
		
		override public function RemotingModel(name:String, controller:Controller)
		{
			super(NAME, controller);
			
			registerClassAlias('com.screenworker.compactmvc.examples.remoting.vo.ExampleServiceVO', ExampleServiceVO);
		}
		
		public function getDescription():void
		{
			
			call('com.screenworker.compactmvc.examples.remoting.ExampleService.getDescription');
		}
		
		override public function errorHandler(message:String):void
		{
			//handle Error here
			Alert.show(message);
		}
		
		override public function resultHandler(result:Object):void
		{
			sendNotification(ApplicationController.REMOTING_RESULT, result);	
		}
		
		override public function registerHandler():void
		{
			gateway = ApplicationConstants.AMF_GATEWAY;
		}

		override public function removeHandler():void
		{
			reset();
		}
		
	}
}